package com.bo.Service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bo.Dao.CompanyDao;
import com.bo.Dao.ProductCommentDao;
import com.bo.Entity.Comment;
import com.bo.Entity.Company;
import com.bo.Entity.MyImage;
import com.bo.Service.CompanyService;
import com.bo.Service.ProductCommentService;


@Service
public class ProductCommentServiceImpl implements ProductCommentService{

	@Autowired
	private ProductCommentDao commentDao;
	
    @Transactional
	public boolean save(Comment comment){
		
		int num=commentDao.save(comment);
		
		if(num>0)
			return true;
		else
			return false;
	}
	
	
	
	@Transactional(readOnly=true)
	public List<Comment> getAllComment(int productId){
		
		return commentDao.getAllComment(productId);
	}
	
	
	@Transactional(readOnly=true)
	public Double getAverageRating(int productId){
		
		return commentDao.getAverageRating(productId);
	}

}
